﻿<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>@ViewData["Title"]</title>
    <script src="http://g.alicdn.com/dingding/dinglogin/0.0.5/ddLogin.js"></script>
    <script>
        var obj = DDLogin({
            id: "login_container",
            goto: "https://oapi.dingtalk.com/connect/oauth2/sns_authorize?appid=1915456124&response_type=code&scope=snsapi_login&state=STATE&redirect_uri=https://www.baidu.com/",
            style: "border:none;background-color:#FFFFFF;",
            width: "365",
            height: "400"
        });

        var hanndleMessage = function(event) {
            var origin = event.origin;
            console.log("origin", event.origin);
            if (origin == "https://login.dingtalk.com") { //判断是否来自ddLogin扫码事件。
                var loginTmpCode = event.data; //拿到loginTmpCode后就可以在这里构造跳转链接进行跳转了
                console.log("loginTmpCode", loginTmpCode);
                window.location.href = "" + loginTmpCode
            }
        };
        if (typeof window.addEventListener != 'undefined') {
            window.addEventListener('message', hanndleMessage, false);
        }
        else if (typeof window.attachEvent != 'undefined') {
            window.attachEvent('onmessage', hanndleMessage);
        }
    </script>
</head>
<body>
    @RenderBody()
    <script src="~/lib/jquery/dist/jquery.min.js"></script>
    <script src="~/lib/bootstrap/dist/js/bootstrap.bundle.min.js"></script>
    <script src="~/js/site.js" asp-append-version="true"></script>
    @RenderSection("Scripts", required: false)
</body>
</html>
